 /*Author: Odd-Arild
  * 
  * */
 function refine() {
    var checkboxes = document.getElementsByClassName('check');
    var checkedboxes = [];
    for(var i = 0; i < checkboxes.length; i++) {
        if(checkboxes[i].checked) {
            checkedboxes.push(checkboxes[i]);
        }
    }

    if(checkedboxes.length > 0) {
        var refData = "";
        $('div#result').empty();
        for(var i = 0; i < checkedboxes.length; i++) {
            refData += checkedboxes[i].name + " = " + checkedboxes[i].value + " & ";


            $.post("RefineDiseases", {
                disease: checkedboxes[i].name,
                checked: checkedboxes[i].value
                },
                function(data) {
                    $('div#result').append(data);
                }
            );
        }
        return false;
    }
}

/*
 * Author: Odd-Arild
 */
function refineSymptoms() {
    var checkboxes = document.getElementsByClassName('check');
    var checkedboxes = [];
    for(var i = 0; i < checkboxes.length; i++) {
        if(checkboxes[i].checked) {
            checkedboxes.push(checkboxes[i]);
        }
    }

    if(checkedboxes.length > 0) {
        $('div#result').empty();
        $('div#result').append("<h2>Results</h2>");
        var s = "";
        for(var i = 0; i < checkedboxes.length; i++) {
            s += checkedboxes[i].name + "_";
        }
        s = s.substring(0, s.length-1);
        $.post("RefineSymptoms", {
            symptom: s
            }, 
            function(data) {
                $('div#result').append(data);
            }
        );
        return false;
    }
}